Pain dummy

Pain :: load dataset

mount_dir = '/Volumes/spacetop_projects_social/analysis/fmri/spm/univariate/model-02_CcEScsA_24dofcsd/1stLevel';
con_list = dir(fullfile(mount_dir, '*/con_0025.nii'));
spm('Defaults','fMRI')
con_fldr = {con_list.folder}; fname = {con_list.name};
con_files = strcat(con_fldr,'/', fname)';
con_data_obj = fmri_data(con_files);
Using default mask: /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/brainmask_canlab.nii
sampleto = '/Volumes/spacetop_projects_social/analysis/fmri/spm/univariate/model-02_CcEScsA_24dofcsd/1stLevel/sub-0007/con_0025.nii'
loading mask. mapping volumes. checking that dimensions and voxel sizes of volumes are the same. Pre-allocating data array. Needed: 23960880 bytes Loading image number: 60 Elapsed time is 7.088712 seconds. Image names entered, but fullpath attribute is empty. Getting path info. Number of unique values in dataset: 5799625 Bit rate: 22.47 bits
contrast_name = {'cue_P', 'cue_V', 'cue_C',...
'cueXcue_P', 'cueXcue_V', 'cueXcue_C',...
'stim_P', 'stim_V', 'stim_C',...
'stimXcue_P', 'stimXcue_V', 'stimXcue_C',...
'stimXint_P', 'stimXint_V', 'stimXint_C',...
'motor', ...
'simple_cue_P', 'simple_cue_V', 'simple_cue_C','simple_cue_G',...
'simple_cueXcue_P', 'simple_cueXcue_V', 'simple_cueXcue_C','simple_cueXcue_G', ...
'simple_stim_P', 'simple_stim_V', 'simple_stim_C','simple_stim_G',...
'simple_stimXcue_P', 'simple_stimXcue_V', 'simple_stimXcue_C','simple_stimXcue_G',...
'simple_stimXint_P', 'simple_stimXint_V','simple_stimXint_C', 'simple_stimXint_G'};

Pain :: check data coverage

m = mean(con_data_obj);
m.dat = sum(~isnan(con_data_obj.dat) & con_data_obj.dat ~= 0, 2);
orthviews(m, 'trans') % display
SPM12: spm_check_registration (v7759) 15:37:13 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
Grouping contiguous voxels: 1 regions
ans = 1×1 cell array
{1×1 region}

Pain :: Plot diagnostics, before l2norm

drawnow; snapnow
[wh_outlier_uncorr, wh_outlier_corr] = plot(con_data_obj)
______________________________________________________________ Outlier analysis ______________________________________________________________ global mean | global mean to var | spatial MAD | Missing values | 0 images Retained 4 components for mahalanobis distance Expected 50% of points within 50% normal ellipsoid, found 25.00% Expected 3.00 outside 95% ellipsoid, found 6 Potential outliers based on mahalanobis distance: Bonferroni corrected: 3 images Cases 11 21 32 Uncorrected: 6 images Cases 11 21 24 30 32 40 Retained 7 components for mahalanobis distance Expected 50% of points within 50% normal ellipsoid, found 48.33% Expected 3.00 outside 95% ellipsoid, found 3 Potential outliers based on mahalanobis distance: Bonferroni corrected: 0 images Cases Uncorrected: 3 images Cases 17 46 56 Mahalanobis (cov and corr, q<0.05 corrected): 3 images Outlier_count Percentage _____________ __________ global_mean 1 1.6667 global_mean_to_variance 2 3.3333 missing_values 0 0 rmssd_dvars 0 0 spatial_variability 4 6.6667 mahal_cov_uncor 6 10 mahal_cov_corrected 3 5 mahal_corr_uncor 3 5 mahal_corr_corrected 0 0 Overall_uncorrected 9 15 Overall_corrected 4 6.6667
SPM12: spm_check_registration (v7759) 15:37:32 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1 (all) /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1 /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
wh_outlier_uncorr = 60×1 logical array
0 0 0 0 0 0 0 0 0 0
wh_outlier_corr = 60×1 logical array
0 0 0 0 0 0 0 0 0 0

Pain :: run robfit

set(gcf,'Visible','on')
figure ('Visible', 'on');
drawnow, snapnow;

Pain :: remove outliers based on plot

con = con_data_obj;
disp(strcat("current length is ", num2str(size(con_data_obj.dat,2))))
current length is 60
%for s = 1:length(wh_outlier_corr)
%disp(strcat("-------subject", num2str(s), "------"))
con.dat = con_data_obj.dat(:,~wh_outlier_corr);
con.image_names = con_data_obj.image_names(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×56 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [56×12 char] fullpath: [60×119 char] files_exist: [60×1 logical] history: {1×4 cell}
con.fullpath = con_data_obj.fullpath(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×56 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [56×12 char] fullpath: [56×119 char] files_exist: [60×1 logical] history: {1×4 cell}
con.files_exist = con_data_obj.files_exist(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×56 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [56×12 char] fullpath: [56×119 char] files_exist: [56×1 logical] history: {1×4 cell}
%end
disp(strcat("after removing ", num2str(sum(wh_outlier_corr)), " participants, size is now ",num2str(size(con.dat,2))))
after removing 4 participants, size is now 56

Pain :: plot diagnostics, after l2norm

imgs2 = con.rescale('l2norm_images');

Pain :: ttest

t = ttest(imgs2);
One-sample t-test Calculating t-statistics and p-values
orthviews(t)
SPM12: spm_check_registration (v7759) 15:37:36 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
ans = 1×1 cell array
{1×1 struct}
drawnow, snapnow;
fdr_t = threshold(t, .05, 'fdr');
Image 1 FDR q < 0.050 threshold is 0.029731 Image 1 41 contig. clusters, sizes 1 to 56735 Positive effect: 49783 voxels, min p-value: 0.00000000 Negative effect: 9581 voxels, min p-value: 0.00000000
orthviews(fdr_t)
SPM12: spm_check_registration (v7759) 15:37:38 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
ans = 1×1 cell array
{1×41 struct}
drawnow, snapnow;
create_figure('montage'); axis off
montage(fdr_t)
Setting up fmridisplay objects
sagittal montage: 1502 voxels displayed, 57862 not displayed on these slices
sagittal montage: 1574 voxels displayed, 57790 not displayed on these slices
sagittal montage: 1536 voxels displayed, 57828 not displayed on these slices
axial montage: 10761 voxels displayed, 48603 not displayed on these slices
axial montage: 11602 voxels displayed, 47762 not displayed on these slices
ans =
fmridisplay with properties: overlay: '/Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img' SPACE: [1×1 struct] activation_maps: {[1×1 struct]} montage: {[1×1 struct] [1×1 struct] [1×1 struct] [1×1 struct] [1×1 struct]} surface: {} orthviews: {} history: {} history_descrip: [] additional_info: ''
drawnow, snapnow;

Vicarious dummy

clear all

Vicarious :: load dataset

mount_dir = '/Volumes/spacetop_projects_social/analysis/fmri/spm/univariate/model-02_CcEScsA_24dofcsd/1stLevel';
con_list = dir(fullfile(mount_dir, '*/con_0026.nii'));
spm('Defaults','fMRI')
con_fldr = {con_list.folder}; fname = {con_list.name};
con_files = strcat(con_fldr,'/', fname)';
con_data_obj = fmri_data(con_files);
Using default mask: /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/brainmask_canlab.nii Direct calls to spm_defauts are deprecated. Please use spm('Defaults',modality) or spm_get_defaults instead.
sampleto = '/Volumes/spacetop_projects_social/analysis/fmri/spm/univariate/model-02_CcEScsA_24dofcsd/1stLevel/sub-0007/con_0026.nii'
loading mask. mapping volumes. checking that dimensions and voxel sizes of volumes are the same. Pre-allocating data array. Needed: 23960880 bytes Loading image number: 60 Elapsed time is 7.404843 seconds. Image names entered, but fullpath attribute is empty. Getting path info. Number of unique values in dataset: 5790398 Bit rate: 22.47 bits
contrast_name = {'cue_P', 'cue_V', 'cue_C',...
'cueXcue_P', 'cueXcue_V', 'cueXcue_C',...
'stim_P', 'stim_V', 'stim_C',...
'stimXcue_P', 'stimXcue_V', 'stimXcue_C',...
'stimXint_P', 'stimXint_V', 'stimXint_C',...
'motor', ...
'simple_cue_P', 'simple_cue_V', 'simple_cue_C','simple_cue_G',...
'simple_cueXcue_P', 'simple_cueXcue_V', 'simple_cueXcue_C','simple_cueXcue_G', ...
'simple_stim_P', 'simple_stim_V', 'simple_stim_C','simple_stim_G',...
'simple_stimXcue_P', 'simple_stimXcue_V', 'simple_stimXcue_C','simple_stimXcue_G',...
'simple_stimXint_P', 'simple_stimXint_V','simple_stimXint_C', 'simple_stimXint_G'};

Vicarious :: check data coverage

m = mean(con_data_obj);
m.dat = sum(~isnan(con_data_obj.dat) & con_data_obj.dat ~= 0, 2);
orthviews(m, 'trans') % display
SPM12: spm_check_registration (v7759) 15:37:55 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
Grouping contiguous voxels: 1 regions
ans = 1×1 cell array
{1×1 region}

Vicarious :: Plot diagnostics, before l2norm

drawnow; snapnow
[wh_outlier_uncorr, wh_outlier_corr] = plot(con_data_obj)
______________________________________________________________ Outlier analysis ______________________________________________________________ global mean | global mean to var | spatial MAD | Missing values | 0 images Retained 8 components for mahalanobis distance Expected 50% of points within 50% normal ellipsoid, found 31.67% Expected 3.00 outside 95% ellipsoid, found 8 Potential outliers based on mahalanobis distance: Bonferroni corrected: 3 images Cases 26 35 42 Uncorrected: 8 images Cases 1 5 6 26 35 37 42 45 Retained 5 components for mahalanobis distance Expected 50% of points within 50% normal ellipsoid, found 46.67% Expected 3.00 outside 95% ellipsoid, found 3 Potential outliers based on mahalanobis distance: Bonferroni corrected: 1 images Cases 48 Uncorrected: 3 images Cases 8 48 53 Mahalanobis (cov and corr, q<0.05 corrected): 4 images Outlier_count Percentage _____________ __________ global_mean 1 1.6667 global_mean_to_variance 0 0 missing_values 0 0 rmssd_dvars 0 0 spatial_variability 1 1.6667 mahal_cov_uncor 8 13.333 mahal_cov_corrected 3 5 mahal_corr_uncor 3 5 mahal_corr_corrected 1 1.6667 Overall_uncorrected 11 18.333 Overall_corrected 4 6.6667
SPM12: spm_check_registration (v7759) 15:38:18 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1 (all) /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1 /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
wh_outlier_uncorr = 60×1 logical array
1 0 0 0 1 1 0 1 0 0
wh_outlier_corr = 60×1 logical array
0 0 0 0 0 0 0 0 0 0

Vicarious :: run robfit

set(gcf,'Visible','on')
figure ('Visible', 'on');
drawnow, snapnow;

Vicarious :: remove outliers based on plot

con = con_data_obj;
disp(strcat("current length is ", num2str(size(con_data_obj.dat,2))))
current length is 60
%for s = 1:length(wh_outlier_corr)
% disp(strcat("-------subject", num2str(s), "------"))
con.dat = con_data_obj.dat(:,~wh_outlier_corr);
con.image_names = con_data_obj.image_names(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×56 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [56×12 char] fullpath: [60×119 char] files_exist: [60×1 logical] history: {1×4 cell}
con.fullpath = con_data_obj.fullpath(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×56 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [56×12 char] fullpath: [56×119 char] files_exist: [60×1 logical] history: {1×4 cell}
con.files_exist = con_data_obj.files_exist(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×56 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [56×12 char] fullpath: [56×119 char] files_exist: [56×1 logical] history: {1×4 cell}
%end
disp(strcat("after removing ", num2str(sum(wh_outlier_corr)), " participants, size is now ",num2str(size(con.dat,2))))
after removing 4 participants, size is now 56

Vicarious :: plot diagnostics, after l2norm

imgs2 = con.rescale('l2norm_images');

Vicarious :: ttest

t = ttest(imgs2);
One-sample t-test Calculating t-statistics and p-values
orthviews(t)
SPM12: spm_check_registration (v7759) 15:38:23 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
ans = 1×1 cell array
{1×1 struct}
drawnow, snapnow;
fdr_t = threshold(t, .05, 'fdr');
Image 1 FDR q < 0.050 threshold is 0.036029 Image 1 14 contig. clusters, sizes 1 to 71856 Positive effect: 54611 voxels, min p-value: 0.00000000 Negative effect: 17340 voxels, min p-value: 0.00000000
orthviews(fdr_t)
SPM12: spm_check_registration (v7759) 15:38:24 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
ans = 1×1 cell array
{1×14 struct}
drawnow, snapnow;
create_figure('montage'); axis off
montage(fdr_t)
Setting up fmridisplay objects
sagittal montage: 1874 voxels displayed, 70077 not displayed on these slices
sagittal montage: 1755 voxels displayed, 70196 not displayed on these slices
sagittal montage: 1778 voxels displayed, 70173 not displayed on these slices
axial montage: 13741 voxels displayed, 58210 not displayed on these slices
axial montage: 14751 voxels displayed, 57200 not displayed on these slices
ans =
fmridisplay with properties: overlay: '/Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img' SPACE: [1×1 struct] activation_maps: {[1×1 struct]} montage: {[1×1 struct] [1×1 struct] [1×1 struct] [1×1 struct] [1×1 struct]} surface: {} orthviews: {} history: {} history_descrip: [] additional_info: ''
drawnow, snapnow;

Cognitive dummy

Cognitive :: load dataset

mount_dir = '/Volumes/spacetop_projects_social/analysis/fmri/spm/univariate/model-02_CcEScsA_24dofcsd/1stLevel';
con_list = dir(fullfile(mount_dir, '*/con_0027.nii'));
spm('Defaults','fMRI')
con_fldr = {con_list.folder}; fname = {con_list.name};
con_files = strcat(con_fldr,'/', fname)';
con_data_obj = fmri_data(con_files);
Using default mask: /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/brainmask_canlab.nii
sampleto = '/Volumes/spacetop_projects_social/analysis/fmri/spm/univariate/model-02_CcEScsA_24dofcsd/1stLevel/sub-0007/con_0027.nii'
loading mask. mapping volumes. checking that dimensions and voxel sizes of volumes are the same. Pre-allocating data array. Needed: 23960880 bytes Loading image number: 60 Elapsed time is 7.182121 seconds. Image names entered, but fullpath attribute is empty. Getting path info. Number of unique values in dataset: 5809373 Bit rate: 22.47 bits
contrast_name = {'cue_P', 'cue_V', 'cue_C',...
'cueXcue_P', 'cueXcue_V', 'cueXcue_C',...
'stim_P', 'stim_V', 'stim_C',...
'stimXcue_P', 'stimXcue_V', 'stimXcue_C',...
'stimXint_P', 'stimXint_V', 'stimXint_C',...
'motor', ...
'simple_cue_P', 'simple_cue_V', 'simple_cue_C','simple_cue_G',...
'simple_cueXcue_P', 'simple_cueXcue_V', 'simple_cueXcue_C','simple_cueXcue_G', ...
'simple_stim_P', 'simple_stim_V', 'simple_stim_C','simple_stim_G',...
'simple_stimXcue_P', 'simple_stimXcue_V', 'simple_stimXcue_C','simple_stimXcue_G',...
'simple_stimXint_P', 'simple_stimXint_V','simple_stimXint_C', 'simple_stimXint_G'};

Cognitive :: check data coverage

m = mean(con_data_obj);
m.dat = sum(~isnan(con_data_obj.dat) & con_data_obj.dat ~= 0, 2);
orthviews(m, 'trans') % display
SPM12: spm_check_registration (v7759) 15:38:43 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
Grouping contiguous voxels: 1 regions
ans = 1×1 cell array
{1×1 region}

Cognitive :: Plot diagnostics, before l2norm

drawnow; snapnow
[wh_outlier_uncorr, wh_outlier_corr] = plot(con_data_obj)
______________________________________________________________ Outlier analysis ______________________________________________________________ global mean | global mean to var | spatial MAD | Missing values | 0 images Retained 4 components for mahalanobis distance Expected 50% of points within 50% normal ellipsoid, found 35.00% Expected 3.00 outside 95% ellipsoid, found 5 Potential outliers based on mahalanobis distance: Bonferroni corrected: 0 images Cases Uncorrected: 5 images Cases 26 35 42 46 54 Retained 12 components for mahalanobis distance Expected 50% of points within 50% normal ellipsoid, found 35.00% Expected 3.00 outside 95% ellipsoid, found 9 Potential outliers based on mahalanobis distance: Bonferroni corrected: 1 images Cases 56 Uncorrected: 9 images Cases 8 31 33 35 46 48 56 57 59 Mahalanobis (cov and corr, q<0.05 corrected): 1 images Outlier_count Percentage _____________ __________ global_mean 3 5 global_mean_to_variance 2 3.3333 missing_values 0 0 rmssd_dvars 0 0 spatial_variability 1 1.6667 mahal_cov_uncor 5 8.3333 mahal_cov_corrected 0 0 mahal_corr_uncor 9 15 mahal_corr_corrected 1 1.6667 Overall_uncorrected 12 20 Overall_corrected 2 3.3333
SPM12: spm_check_registration (v7759) 15:39:04 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1 (all) /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1 /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
wh_outlier_uncorr = 60×1 logical array
0 0 0 0 0 0 0 1 0 0
wh_outlier_corr = 60×1 logical array
0 0 0 0 0 0 0 0 0 0

Cognitive :: run robfit

set(gcf,'Visible','on')
figure ('Visible', 'on');
drawnow, snapnow;

Cognitive :: remove outliers based on plot

con = con_data_obj;
disp(strcat("current length is ", num2str(size(con_data_obj.dat,2))))
current length is 60
%for s = 1:length(wh_outlier_corr)
% disp(strcat("-------subject", num2str(s), "------"))
con.dat = con_data_obj.dat(:,~wh_outlier_corr);
con.image_names = con_data_obj.image_names(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×58 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [58×12 char] fullpath: [60×119 char] files_exist: [60×1 logical] history: {1×4 cell}
con.fullpath = con_data_obj.fullpath(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×58 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [58×12 char] fullpath: [58×119 char] files_exist: [60×1 logical] history: {1×4 cell}
con.files_exist = con_data_obj.files_exist(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×58 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [58×12 char] fullpath: [58×119 char] files_exist: [58×1 logical] history: {1×4 cell}
%end
disp(strcat("after removing ", num2str(sum(wh_outlier_corr)), " participants, size is now ",num2str(size(con.dat,2))))
after removing 2 participants, size is now 58

Cognitive:: plot diagnostics, after l2norm

imgs2 = con.rescale('l2norm_images');

Cognitive :: ttest

t = ttest(imgs2);
One-sample t-test Calculating t-statistics and p-values
orthviews(t)
SPM12: spm_check_registration (v7759) 15:39:08 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
ans = 1×1 cell array
{1×1 struct}
drawnow, snapnow;
fdr_t = threshold(t, .05, 'fdr');
Image 1 FDR q < 0.050 threshold is 0.038939 Image 1 9 contig. clusters, sizes 1 to 77707 Positive effect: 49712 voxels, min p-value: 0.00000000 Negative effect: 28053 voxels, min p-value: 0.00000000
orthviews(fdr_t)
SPM12: spm_check_registration (v7759) 15:39:09 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
ans = 1×1 cell array
{1×9 struct}
drawnow, snapnow;
create_figure('montage'); axis off
montage(fdr_t)
Setting up fmridisplay objects
sagittal montage: 1951 voxels displayed, 75814 not displayed on these slices
sagittal montage: 1943 voxels displayed, 75822 not displayed on these slices
sagittal montage: 1895 voxels displayed, 75870 not displayed on these slices
axial montage: 14782 voxels displayed, 62983 not displayed on these slices
axial montage: 15606 voxels displayed, 62159 not displayed on these slices
ans =
fmridisplay with properties: overlay: '/Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img' SPACE: [1×1 struct] activation_maps: {[1×1 struct]} montage: {[1×1 struct] [1×1 struct] [1×1 struct] [1×1 struct] [1×1 struct]} surface: {} orthviews: {} history: {} history_descrip: [] additional_info: ''
drawnow, snapnow;

General dummy

General :: load dataset

mount_dir = '/Volumes/spacetop_projects_social/analysis/fmri/spm/univariate/model-02_CcEScsA_24dofcsd/1stLevel';
con_list = dir(fullfile(mount_dir, '*/con_0028.nii'));
spm('Defaults','fMRI')
con_fldr = {con_list.folder}; fname = {con_list.name};
con_files = strcat(con_fldr,'/', fname)';
con_data_obj = fmri_data(con_files);
Using default mask: /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/brainmask_canlab.nii
sampleto = '/Volumes/spacetop_projects_social/analysis/fmri/spm/univariate/model-02_CcEScsA_24dofcsd/1stLevel/sub-0007/con_0028.nii'
loading mask. mapping volumes. checking that dimensions and voxel sizes of volumes are the same. Pre-allocating data array. Needed: 23960880 bytes Loading image number: 60 Elapsed time is 5.927483 seconds. Image names entered, but fullpath attribute is empty. Getting path info. Number of unique values in dataset: 5782238 Bit rate: 22.46 bits
contrast_name = {'cue_P', 'cue_V', 'cue_C',...
'cueXcue_P', 'cueXcue_V', 'cueXcue_C',...
'stim_P', 'stim_V', 'stim_C',...
'stimXcue_P', 'stimXcue_V', 'stimXcue_C',...
'stimXint_P', 'stimXint_V', 'stimXint_C',...
'motor', ...
'simple_cue_P', 'simple_cue_V', 'simple_cue_C','simple_cue_G',...
'simple_cueXcue_P', 'simple_cueXcue_V', 'simple_cueXcue_C','simple_cueXcue_G', ...
'simple_stim_P', 'simple_stim_V', 'simple_stim_C','simple_stim_G',...
'simple_stimXcue_P', 'simple_stimXcue_V', 'simple_stimXcue_C','simple_stimXcue_G',...
'simple_stimXint_P', 'simple_stimXint_V','simple_stimXint_C', 'simple_stimXint_G'};

General :: check data coverage

m = mean(con_data_obj);
m.dat = sum(~isnan(con_data_obj.dat) & con_data_obj.dat ~= 0, 2);
orthviews(m, 'trans') % display
SPM12: spm_check_registration (v7759) 15:39:27 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
Grouping contiguous voxels: 1 regions
ans = 1×1 cell array
{1×1 region}

General :: Plot diagnostics, before l2norm

drawnow; snapnow
[wh_outlier_uncorr, wh_outlier_corr] = plot(con_data_obj)
______________________________________________________________ Outlier analysis ______________________________________________________________ global mean | global mean to var | spatial MAD | Missing values | 0 images Retained 3 components for mahalanobis distance Expected 50% of points within 50% normal ellipsoid, found 35.00% Expected 3.00 outside 95% ellipsoid, found 4 Potential outliers based on mahalanobis distance: Bonferroni corrected: 1 images Cases 21 Uncorrected: 4 images Cases 11 21 24 30 Retained 10 components for mahalanobis distance Expected 50% of points within 50% normal ellipsoid, found 40.00% Expected 3.00 outside 95% ellipsoid, found 5 Potential outliers based on mahalanobis distance: Bonferroni corrected: 2 images Cases 8 56 Uncorrected: 5 images Cases 8 30 48 56 57 Mahalanobis (cov and corr, q<0.05 corrected): 3 images Outlier_count Percentage _____________ __________ global_mean 1 1.6667 global_mean_to_variance 1 1.6667 missing_values 0 0 rmssd_dvars 0 0 spatial_variability 1 1.6667 mahal_cov_uncor 4 6.6667 mahal_cov_corrected 1 1.6667 mahal_corr_uncor 5 8.3333 mahal_corr_corrected 2 3.3333 Overall_uncorrected 8 13.333 Overall_corrected 3 5
SPM12: spm_check_registration (v7759) 15:39:47 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1 (all) /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1 /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
Grouping contiguous voxels: 1 regions
wh_outlier_uncorr = 60×1 logical array
0 0 0 0 0 0 0 1 0 0
wh_outlier_corr = 60×1 logical array
0 0 0 0 0 0 0 1 0 0

General :: run robfit

set(gcf,'Visible','on')
figure ('Visible', 'on');
drawnow, snapnow;

General :: remove outliers based on plot

con = con_data_obj;
disp(strcat("current length is ", num2str(size(con_data_obj.dat,2))))
current length is 60
%for s = 1:length(wh_outlier_corr)
% disp(strcat("-------subject", num2str(s), "------"))
con.dat = con_data_obj.dat(:,~wh_outlier_corr);
con.image_names = con_data_obj.image_names(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×57 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [57×12 char] fullpath: [60×119 char] files_exist: [60×1 logical] history: {1×4 cell}
con.fullpath = con_data_obj.fullpath(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×57 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [57×12 char] fullpath: [57×119 char] files_exist: [60×1 logical] history: {1×4 cell}
con.files_exist = con_data_obj.files_exist(~wh_outlier_corr,:)
con =
fmri_data with properties: source_notes: 'Info about image source here' X: [] mask: [1×1 fmri_mask_image] mask_descrip: 'REMOVED: CHANGED SPACE' images_per_session: [] Y: [] Y_names: [] Y_descrip: 'Behavioral or outcome data matrix.' covariates: [] covariate_names: {''} covariates_descrip: 'Nuisance covariates associated with data' history_descrip: 'Cell array of names of methods applied to this data, in order' additional_info: [0×0 struct] metadata_table: [0×0 table] dat: [99837×57 single] dat_descrip: [] volInfo: [1×1 struct] removed_voxels: 0 removed_images: 0 image_names: [57×12 char] fullpath: [57×119 char] files_exist: [57×1 logical] history: {1×4 cell}
%end
disp(strcat("after removing ", num2str(sum(wh_outlier_corr)), " participants, size is now ",num2str(size(con.dat,2))))
after removing 3 participants, size is now 57

General:: plot diagnostics, after l2norm

imgs2 = con.rescale('l2norm_images');

General :: ttest

t = ttest(imgs2);
One-sample t-test Calculating t-statistics and p-values
orthviews(t)
SPM12: spm_check_registration (v7759) 15:39:51 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
ans = 1×1 cell array
{1×1 struct}
drawnow, snapnow;
fdr_t = threshold(t, .05, 'fdr');
Image 1 FDR q < 0.050 threshold is 0.038824 Image 1 16 contig. clusters, sizes 1 to 77409 Positive effect: 64088 voxels, min p-value: 0.00000000 Negative effect: 13479 voxels, min p-value: 0.00000000
orthviews(fdr_t)
SPM12: spm_check_registration (v7759) 15:39:52 - 01/06/2022 ======================================================================== Display /Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img,1
ans = 1×1 cell array
{1×16 struct}
drawnow, snapnow;
create_figure('montage'); axis off
montage(fdr_t)
Setting up fmridisplay objects
sagittal montage: 1919 voxels displayed, 75648 not displayed on these slices
sagittal montage: 1891 voxels displayed, 75676 not displayed on these slices
sagittal montage: 1864 voxels displayed, 75703 not displayed on these slices
axial montage: 14573 voxels displayed, 62994 not displayed on these slices
axial montage: 15576 voxels displayed, 61991 not displayed on these slices
ans =
fmridisplay with properties: overlay: '/Users/h/Documents/MATLAB/CanlabCore/CanlabCore/canlab_canonical_brains/Canonical_brains_surfaces/keuken_2014_enhanced_for_underlay.img' SPACE: [1×1 struct] activation_maps: {[1×1 struct]} montage: {[1×1 struct] [1×1 struct] [1×1 struct] [1×1 struct] [1×1 struct]} surface: {} orthviews: {} history: {} history_descrip: [] additional_info: ''
drawnow, snapnow;